#@cmsLayout()

#define cmsContent()
<div class="cms-breadcrumb">
	<i class="layui-icon layui-icon-flag"></i>
	<span class="layui-breadcrumb">
	  	<a href="">站点管理</a>
	  	<a><cite>公司信息</cite></a>
	</span>
</div>

<div class="body-card layui-card">
	<form id="updateCompany" action="#(ctx)/cmsCompany/updateCompany" class="layui-form" method="post" onsubmit="return false;">
  		#(token)
  		<input class="layui-hide" type="text" name="id" value="#(company.id??)">
  		<div class="layui-form-item">
    		<label class="layui-form-label">公司名称</label>
    		<div class="layui-input-inline">
      			<input type="text" name="name" class="layui-input" value="#(company.name??)">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">公司地址</label>
    		<div class="layui-input-inline">
      			<input type="text" name="address" class="layui-input" value="#(company.address??)">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">邮政编码</label>
    		<div class="layui-input-inline">
      			<input type="text" name="postCode" class="layui-input" value="#(company.postCode??)">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">联系人</label>
    		<div class="layui-input-inline">
      			<input type="text" name="contacts" value="#(company.contacts??)" class="layui-input">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">手机号</label>
    		<div class="layui-input-inline">
      			<input type="text" name="mobile" value="#(company.mobile??)" class="layui-input">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">座机号</label>
    		<div class="layui-input-inline">
      			<input type="text" name="telephone" value="#(company.telephone??)" class="layui-input">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">传真</label>
    		<div class="layui-input-inline">
      			<input type="text" name="fax" value="#(company.fax??)" class="layui-input">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">QQ</label>
    		<div class="layui-input-inline">
      			<input type="text" name="qq" value="#(company.qq??)" class="layui-input">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">电子邮箱</label>
    		<div class="layui-input-inline">
      			<input type="text" name="email" value="#(company.email??)" class="layui-input">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">营业执照号</label>
    		<div class="layui-input-inline">
      			<input type="text" name="license" value="#(company.license??)" class="layui-input">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">网址</label>
    		<div class="layui-input-inline">
      			<input type="text" name="website" value="#(company.website??)" class="layui-input">
    		</div>
  		</div>
  		<div id="logo-item" class="layui-form-item #if(!logo) layui-hide #end">###已经上传的logo图
    		<label class="layui-form-label">已传logo</label>
    		<div id="logo-input" class="layui-input-block">
    			#if(logo)
    			<input type='checkbox' name='logo' value='#(logo.id)' title='#(logo.originalName)' checked>
    			<a href="javascript:;" onclick="viewImg('#(logo.id)')" class='layui-btn layui-btn-sm'>预览</a>
    			#end
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">公司logo</label>
    		<div class="layui-input-block">
      			<button type="button" class="layui-btn layui-btn-primary" id="logo">上传logo图片</button>
      			<span class="layui-word-aux">最多只能有一张图，多次上传将以最后一张为准</span>
    		</div>
  		</div>
  		<div id="WeChat-item" class="layui-form-item #if(!WeChatImg) layui-hide #end">###已经上传的微信图片
    		<label class="layui-form-label">已传微信图</label>
    		<div id="WeChat-input" class="layui-input-block">
    			#if(WeChatImg)
    			<input type='checkbox' name='weChatImg' value='#(WeChatImg.id)' title='#(WeChatImg.originalName)' checked>
    			<a href="javascript:;" onclick="viewImg('#(WeChatImg.id)')" class='layui-btn layui-btn-sm'>预览</a>
    			#end
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">微信图片</label>
    		<div class="layui-input-block">
      			<button type="button" class="layui-btn layui-btn-primary" id="WeChat">上传微信图片</button>
      			<span class="layui-word-aux">最多只能有一张图，多次上传将以最后一张为准</span>
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<label class="layui-form-label">其他信息</label>
    		<div class="layui-input-block">
      			<input type="text" name="remark" value="#(company.remark??)" class="layui-input">
    		</div>
  		</div>
  		<div class="layui-form-item">
    		<div class="layui-input-block">
      			<button class="layui-btn" onclick="ajaxSaveForm('#updateCompany')">保存</button>
      			<a class="layui-btn layui-btn-primary" href="javascript:history.go(-1);">返回</a>
    		</div>
  		</div>
  	</form>
</div>

#@jsInit()

###图片上传
<script type="text/javascript">
	var upload = layui.upload;
	// logo上传处理
	upload.render({
	    elem: '#logo', //绑定元素
	    url: '/file/uploadThumbnail', //上传接口
	    data: {type: 'thumbnail'},//其他额外参数，此处是缩略图
	    accept: 'images', //接受上传的类型
	    acceptMime: 'image/*', //只显示图片文件
	    exts: '#(SiteInfo.thumbnailSuffix)', //允许的文件扩展名，图片是相对固定的
	    size: #(SiteInfo.imgMaxSize.toInt()*1024), //允许的大小，单位KB，使用siteInfo中的变量
	    done: function(res, index, upload){//上传接口请求成功的回调
	    	if('ok'==res.state){//后台返回成功
	    		layer.msg(res.msg);
	    		$("#logo-item").removeClass("layui-hide");
	    		var html = "<input type='checkbox' name='logo' value='"+res.fileId+"' title='"+res.fileName+"' checked>";
	    		html = html + "<a href='javascript:;' onclick='viewImg("+res.fileId+")' class='layui-btn layui-btn-sm'>预览</a>";
	    		$("#logo-input").html(html);
	    		form.render("checkbox");
	    	} else {//后台返回失败
	    		layer.msg(res.msg);
	    	}
	    },
	    error: function(index, upload){//上传请求失败的回调
	    	layer.msg("文件上传失败");
	    }
	});
	
	// 微信图片上传处理
	upload.render({
	    elem: '#WeChat', //绑定元素
	    url: '/file/uploadThumbnail', //上传接口
	    data: {type: 'thumbnail'},//其他额外参数，此处是缩略图
	    accept: 'images', //接受上传的类型
	    acceptMime: 'image/*', //只显示图片文件
	    exts: '#(SiteInfo.thumbnailSuffix)', //允许的文件扩展名，图片是相对固定的
	    size: #(SiteInfo.imgMaxSize.toInt()*1024), //允许的大小，单位KB，使用siteInfo中的变量
	    done: function(res, index, upload){//上传接口请求成功的回调
	    	if('ok'==res.state){//后台返回成功
	    		layer.msg(res.msg);
	    		$("#WeChat-item").removeClass("layui-hide");
	    		var html = "<input type='checkbox' name='weChatImg' value='"+res.fileId+"' title='"+res.fileName+"' checked>";
	    		html = html + "<a href='javascript:;' onclick='viewImg("+res.fileId+")' class='layui-btn layui-btn-sm'>预览</a>";
	    		$("#WeChat-input").html(html);
	    		form.render("checkbox");
	    	} else {//后台返回失败
	    		layer.msg(res.msg);
	    	}
	    },
	    error: function(index, upload){//上传请求失败的回调
	    	layer.msg("文件上传失败");
	    }
	});
</script>

#end